import { request } from '@/utils/request'

// 获取商品
export const getGoodsInfo = (id, token, extra = {}) =>
  request(
    '/goods/goods_detail',
    Object.assign(
      {
        goods_id: id,
        key: token
      },
      extra
    ),
    'GET'
  )
// 秒杀订单判断
export const goodsSpikeActivityOrder = (id, goodsSpike, token, extra = {}) =>
  request(
    '/goods/goods_spike_activity_order',
    Object.assign(
      {
        goods_id: id,
        goods_spike_activity_startdate: goodsSpike,
        key: token
      },
      extra
    ),
    'GET'
  )
// 商品评论
export const getReviewList = (id, type, page) =>
  request(
    '/goods/goods_evaluate',
    {
      goods_id: id,
      type: type,
      page: page
    },
    'GET'
  )
// 组合搭配
export const productAccessoryList = id =>
  request(
    '/goods/get_bundling',
    {
      goods_id: id
    },
    'GET'
  )
// 收藏商品
export const productLike = id =>
  request('/Memberfavorites/favorites_add', {
    goods_id: id
  })
// 取消收藏
export const productUnlike = id =>
  request('/Memberfavorites/favorites_del', 'POST', {
    fav_id: id
  })
// 获取商品
export const getGoodsConsult = (params, id) =>
  request(
    'goods/consulting_list',
    {
      goods_id: id,
      page: params.page,
      per_page: params.per_page
    },
    'GET'
  )

export const addGoodsConsult = (id, typeId, content, token) =>
  request('goods/save_consult', {
    goods_content: content,
    consult_type_id: typeId,
    goods_id: id,
    key: token
  })
